package org.grow.loginto.filter;

import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author: xwg
 * @CreateDate: 21-6-14
 */
//@Component
public class LeaveNumberFilter extends OncePerRequestFilter {
    private AtomicInteger atomicInteger = new AtomicInteger(0);
    @Override
    protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
        int i = atomicInteger.incrementAndGet();
        System.out.println("当前业务的访问量是: "+i);
        filterChain.doFilter(httpServletRequest,httpServletResponse);
    }
}
